<template>
    <div class="parent">
        <header class="header">
            <x-header class="headerContent" :left-options="{backText: ''}"><span class="title">缴费记录</span></x-header>
        </header>
        <scroller lock-x @on-scroll="onScroll" ref="scrollerEvent">
            <div class="main" v-if="fullShow">
                <ul class="list">
                    <li class="listItem" v-for="(item, index) in datalist" :key="index">
                        <div class="left">
                            <!-- <p class="name_title">{{item.title}}</p> -->
                            <p class="name_title">{{item.invoices_style}}</p>
                            <p class="name_date">{{item.payment_date}}</p>
                        </div>
                        <div class="right">
                            <p class="name_explain">{{item.payment_value}}</p>
                        </div>
                    </li>
                </ul>
            </div>
            <div class="main" v-else>
                <div class="contentNull">
                    <span>没有缴费记录</span>
                </div>
            </div>
        </scroller>
    </div>
</template>
<script>
import { XHeader, Scroller } from 'vux'
import API from '../../config/api_user.js'
export default {
    name: 'Paymentrecord',
    data () {
        return {
            datalist: [],
            scrollTop: 0,
            fullShow: null
        }
    },
    components: {
        XHeader,
        Scroller
    },
    created () {
        let userid = JSON.parse(sessionStorage.getItem('userInfo')).page.userid
        let params ={
            userid: userid
        }
        API.paymentList(params).then(res => {
            if (res.page.length == 0) {
                this.fullShow = false
            } else {
                this.fullShow = true
                res.page.map((item, index) => {
                    // console.log(item)
                    if (item.payment_state == '已缴费') {
                        this.datalist.push(item)
                    }
                })
                // var t = new Array(this.datalist.length);
                // this.count = t;
            }
            
        })


    },
    mounted () {
        this.$nextTick(() => {
            this.$refs.scrollerEvent.reset({top: 0})
        })
    },
    methods: {
        onScroll (pos) {
            this.scrollTop = pos.top
        },
    }
}
</script>
<style scoped lang="less">
.parent{
    width: 100%;
    height: 100%;
    background: rgba(250, 250, 250, 1);
}
.header{
    width: 100%;
}
.title{
    font-size: 16px;
    font-family:ArialMT;
    color:rgba(255,255,255,1);
    letter-spacing:1px;
}
.headerContent{
    width: 100%;
    background:linear-gradient(135deg,rgba(255,199,38,1) 0%,rgba(249,151,22,1) 100%);
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
}
.main{
    width: 100%;
    flex: 1;
    overflow: hidden;
    padding-bottom: 2.666667rem;
    .list{
        width: 100%;
        .listItem{
            width: 100%;
            height: 1.946667rem;
            background: #fff;
            margin-top: 0.1rem;
            padding: 0 .48rem;
            position: relative;
            display: flex;
            flex-direction: row;
            justify-content: space-between;
            align-items: center;
            .left{
                width: 6.666667rem;
                height: 1.946667rem;
                display: flex;
                flex-direction: column;
                justify-content: center;
                align-items: center;
                .name_title{
                    width: 100%;
                    height: .7rem;
                    display: flex;
                    flex-direction: row;
                    justify-content: flex-start;
                    align-items: center;
                    font-size:14px;
                    font-family:ArialMT;
                    color:rgba(82,82,82,1);
                    letter-spacing:1px;
                }
                .name_date {
                    width: 100%;
                    height: .7rem;
                    display: flex;
                    flex-direction: row;
                    justify-content: flex-start;
                    align-items: center;
                    font-size:12px;
                    font-family:ArialMT;
                    color:rgba(204,204,204,1);
                    letter-spacing:1px;
                }
            }
            .right{
                width: 2rem;
                height: 100%;
                display: flex;
                flex-direction: row;
                justify-content: center;
                align-items: center;
                .name_explain{
                    width: 100%;
                    height: 100%;
                    display: flex;
                    flex-direction: row;
                    justify-content: flex-end;
                    align-items: center;
                    font-size:12px;
                    font-family:ArialMT;
                    color:rgba(82,82,82,1);
                    letter-spacing:1px;
                }
            }
        }
        .listItem:after{
            content: '';
            position: absolute;
            left: 0;
            bottom: 0;
            background: #cccccc;
            width: 100%;
            height: 1px;
            -webkit-transform: scaleY(0.5);
            transform: scaleY(0.5);
            -webkit-transform-origin: 0 0;
            transform-origin: 0 0;
        }
    }
    .contentNull{
        width: 100%;
        height: 1.333333rem;
        display: flex;
        flex-direction: row;
        justify-content: center;
        align-items: center;
        span{
            font-size: 16px;
            font-family:ArialMT;
            letter-spacing:1px;
        }
    }
}
</style>
